package com.example.android.nfc;

import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.util.Log;

import com.example.android.nfc.record.TextRecord;

public class GetRecordText {
	public GetRecordText() {

	}

	public String get(NdefMessage message) {
		return getRecordText(message.getRecords());
	}

	private String getRecordText(NdefRecord[] records) {
		String getText = new String();
		for (NdefRecord record : records) {
			if (TextRecord.isText(record)) {
				TextRecord tr = TextRecord.parse(record);
				Log.w("GetRecordText", "" + tr.getText().trim());
				getText = tr.getText().trim();
			}
		}
		return getText;

	}

}
